package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.bean.EUDataGridResult;
import com.taotao.common.bean.TaotaoResult;
import com.taotao.pojo.TbItem;
import com.taotao.service.ItemService;

@Controller
@RequestMapping("/item")
public class ItemController {
	
	@Autowired
	private ItemService itemService;
	

	@RequestMapping("/list")
	@ResponseBody
	public EUDataGridResult getItemList(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "20") Integer rows) {
		EUDataGridResult result = itemService.getItemList(page, rows);
		return result;
	}
	
	@RequestMapping(value="/save",method=RequestMethod.POST)
	@ResponseBody
	public TaotaoResult createItem(TbItem item,String desc,String itemParam) throws Exception {
		TaotaoResult result = itemService.createItem(item,desc, itemParam);
		return result;
		
	}
	
	@RequestMapping(value="/update",method=RequestMethod.POST)
	@ResponseBody
	public TaotaoResult updateItem(TbItem item,String desc,String itemParam) throws Exception {
		TaotaoResult result = itemService.updateItem(item, desc,itemParam);
		return result;
	}
	
	@RequestMapping("/query/desc/{itemId}")
	@ResponseBody
	public TaotaoResult getItemDesc(@PathVariable long itemId) {
		TaotaoResult itemDesc = itemService.getItemDesc(itemId);
		return itemDesc;
	}
	
	/**
	 * 
	 */
	@RequestMapping("/param/item/query/{itemId}")
	@ResponseBody
	public TaotaoResult getItemParamItem(@PathVariable long itemId) {
		return null;
	}
	
}
